<html lang="en">
<head>
    <title>社区回答管理</title>
<#include "../common/header.ftl">

    <link href="/js/plugins/jqPaginator/jqPagination.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/js/plugins/jqPaginator/jq-paginator.min.js"></script>

    <script type="text/javascript">
        $(function () {
            //编辑/添加
            $(".inputBtn").click(function () {
                //弹出模态框
                $("#editModal").modal("show");

                $("#treeview").html("");
                //数据复原
                $("#editForm").clearForm(true);

                //目的地回显数据
                var data = $(this).data("json");
                if (data) {
                    $("input[name='id']").val(data.id);

                    $("textarea[name='info']").val(data.info);

                }
            });

            $('.lookBtn').click(function () {
                $('.modal-title').empty();
                $('.modal-body').empty();
                var id = $(this).data('id');
                var title = $(this).data('title');
                $.get('/answer/getContent',{id:id},function (data) {
                    $('.modal-title').html(title);
                    $('.modal-body').html(data.data.content);
                })
                $('#contentModal').modal('show');
            })



            //修改状态
            $(".hotBtn").click(function () {
                var status = $(this).data("status");
                var id = $(this).data("id");
                $.get("/answer/upByStatus", {status: status, id: id}, function (data) {
                    if (data.success) {
                        window.location.reload();
                    } else {
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            })
        })
    </script>


</head>
<body>
<!--左侧菜单回显变量设置-->
<#assign currentMenu="answer">

<div class="container-fluid " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">社区回答管理</h1>
                </div>
            </div>
        <#setting number_format="#">
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/answer/list" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
            </form>

            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>回答的标题</th>
                    <th>用户名</th>
                    <th>回答标题</th>
                    <th>收藏数</th>
                    <th>是否金牌回答</th>
                    <th>回答时间</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
            <#list pageInfo.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td>${entity.ask.title!}</td>
                    <td>${entity.user.nickname!}</td>
                    <td>${(entity.title)! }</td>
                    <td>${(entity.collectnum)!}</td>
                    <td>${(entity.gold == 1)?string('金牌回答','否')}</td>
                    <td>${entity.nowTime?string("yyyy-MM-dd")}</td>
                    <td>${(entity.statusString)!}</td>

                    <td>
                        <#if entity.status == 1>
                            <a class="btn btn-primary btn-xs hotBtn" href="JavaScript:;" data-status="0"
                               data-id="${entity.id}">
                                <span class="glyphicon glyphicon-tag"></span> 取消回答
                            </a>
                        <#else >
                            <a class="btn btn-primary btn-xs" href="JavaScript:;" data-status="1"
                               data-id="${entity.id}">
                                <span class="glyphicon glyphicon-tag"></span> 发布
                            </a>
                        </#if>
                        <a href="javascript:;" class="btn btn-primary btn-xs lookBtn" data-title="${(entity.title)!}"
                           data-id="${(entity.id)!}">查看文章</a>

                        <a class="btn btn-primary btn-xs hotBtn" href="JavaScript:;" data-status="3"
                           data-id="${entity.id}">
                            <span class="glyphicon glyphicon-tag"></span> 金牌回答
                        </a>


                        <a class="btn btn-danger btn-xs hotBtn" href="JavaScript:;" data-status="-1"
                           data-id="${entity.id}">
                            <span class="glyphicon glyphicon-tag"></span> 拒绝
                        </a>

                    </td>
                </tr>
            </#list>
            </table>
        <#--分页-->
        <#include "../common/page.ftl"/>
        </div>
    </div>
</div>
<#--模态框-->
<div class="modal fade" id="contentModal"
     tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">文章内容</h4>
            </div>
            <div class="modal-body">

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>